package com.hsjk.szwj.module.smedia.controller.admin.production;

import com.hsjk.szwj.framework.common.pojo.CommonResult;
import com.hsjk.szwj.module.smedia.controller.admin.production.vo.AddEditingProjectMaterialsReqVO;
import com.hsjk.szwj.module.smedia.controller.admin.production.vo.AddEditingProjectMaterialsRespVO;
import com.hsjk.szwj.module.smedia.controller.admin.production.vo.CreateEditingProjectReqVO;
import com.hsjk.szwj.module.smedia.controller.admin.production.vo.CreateEditingProjectRespVO;
import com.hsjk.szwj.module.smedia.controller.admin.production.vo.DeleteEditingProjectMaterialsReqVO;
import com.hsjk.szwj.module.smedia.controller.admin.production.vo.DeleteEditingProjectMaterialsRespVO;
import com.hsjk.szwj.module.smedia.controller.admin.production.vo.DeleteEditingProjectsRespVO;
import com.hsjk.szwj.module.smedia.controller.admin.production.vo.EditingProjectMaterialsRespVO;
import com.hsjk.szwj.module.smedia.controller.admin.production.vo.GetEditingProjectReqVO;
import com.hsjk.szwj.module.smedia.controller.admin.production.vo.GetEditingProjectRespVO;
import com.hsjk.szwj.module.smedia.controller.admin.production.vo.SearchEditingProjectReqVO;
import com.hsjk.szwj.module.smedia.controller.admin.production.vo.SearchEditingProjectRespVO;
import com.hsjk.szwj.module.smedia.controller.admin.production.vo.SubmitMediaProducingJobReqVO;
import com.hsjk.szwj.module.smedia.controller.admin.production.vo.SubmitMediaProducingJobRespVO;
import com.hsjk.szwj.module.smedia.controller.admin.production.vo.UpdateEditingProjectReqVO;
import com.hsjk.szwj.module.smedia.controller.admin.production.vo.UpdateEditingProjectRespVO;
import com.hsjk.szwj.module.smedia.service.production.ICloudEdit;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.hsjk.szwj.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 云剪辑管理")
@RestController
@RequestMapping("/system/cloud-edit-manager")
@Validated
public class CloudEditController {
    @Resource
    private ICloudEdit cloudEdit;

    @GetMapping("/get-editing-project-materials")
    @Operation(summary = "获取剪辑工程关联素材")
    @PreAuthorize("@ss.hasPermission('system:cloud-edit-manager:query-project-materials')")
    public CommonResult<EditingProjectMaterialsRespVO> getEditingProjectMaterials(
            @RequestParam("projectId") String projectId) {
        return success(cloudEdit.getEditingProjectMaterials(projectId));
    }

    @PostMapping("/create-editing-project")
    @Operation(summary = "创建云剪辑工程")
    @PreAuthorize("@ss.hasPermission('system:cloud-edit-manager:create-project')")
    public CommonResult<CreateEditingProjectRespVO> createEditingProject(
            @Valid @RequestBody CreateEditingProjectReqVO reqVO) {
        return success(cloudEdit.createEditingProject(reqVO));
    }

    @PostMapping("/add-editing-project-materials")
    @Operation(summary = "新增剪辑工程关联素材")
    @PreAuthorize("@ss.hasPermission('system:cloud-edit-manager:add-project-materials')")
    public CommonResult<AddEditingProjectMaterialsRespVO> addEditingProjectMaterials(
            @Valid @RequestBody AddEditingProjectMaterialsReqVO reqVO) {
        return success(cloudEdit.addEditingProjectMaterials(reqVO));
    }

    @PostMapping("/delete-editing-project-materials")
    @Operation(summary = "删除剪辑工程管理素材")
    @PreAuthorize("@ss.hasPermission('system:cloud-edit-manager:delete-project-materials')")
    public CommonResult<DeleteEditingProjectMaterialsRespVO> deleteEditingProjectMaterials(
            @Valid @RequestBody DeleteEditingProjectMaterialsReqVO reqVO) {
        return success(cloudEdit.deleteEditingProjectMaterials(reqVO));
    }

    @PostMapping("/get-editing-project")
    @Operation(summary = "获取单个云剪辑工程信息")
    @PreAuthorize("@ss.hasPermission('system:cloud-edit-manager:get-project')")
    public CommonResult<GetEditingProjectRespVO> getEditingProject(
            @Valid @RequestBody GetEditingProjectReqVO reqVO) {
        return success(cloudEdit.getEditingProject(reqVO));
    }

    @PostMapping("/update-editing-project")
    @Operation(summary = "修改云剪辑工程")
    @PreAuthorize("@ss.hasPermission('system:cloud-edit-manager:update-project')")
    public CommonResult<UpdateEditingProjectRespVO> updateEditingProject(
            @Valid @RequestBody UpdateEditingProjectReqVO reqVO) {
        return success(cloudEdit.updateEditingProject(reqVO));
    }

    @PostMapping("/submit-media-producing-job")
    @Operation(summary = "提交剪辑合成作业")
    @PreAuthorize("@ss.hasPermission('system:cloud-edit-manager:submit-media-producing-job')")
    public CommonResult<SubmitMediaProducingJobRespVO> submitMediaProducingJob(
            @Valid @RequestBody SubmitMediaProducingJobReqVO reqVO) {
        return success(cloudEdit.submitMediaProducingJob(reqVO));
    }

    @GetMapping("/delete-editing-projects")
    @Operation(summary = "删除云剪辑工程")
    @PreAuthorize("@ss.hasPermission('system:cloud-edit-manager:delete-editing-projects')")
    public CommonResult<DeleteEditingProjectsRespVO> deleteEditingProjects(
            @RequestParam("projectId") String projectId) {
        return success(cloudEdit.deleteEditingProjects(projectId));
    }

    @PostMapping("/search-editing-project")
    @Operation(summary = "搜索云剪辑工程")
    @PreAuthorize("@ss.hasPermission('system:cloud-edit-manager:search-editing-project')")
    public CommonResult<SearchEditingProjectRespVO> searchEditingProject(
            @Valid @RequestBody SearchEditingProjectReqVO reqVO) {
        return success(cloudEdit.searchEditingProject(reqVO));
    }
}
